package com.hbo.timer.quartz;

import org.quartz.JobBuilder;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SimpleScheduleBuilder;
import org.quartz.SimpleTrigger;
import org.quartz.Trigger;
import org.quartz.TriggerBuilder;
import org.quartz.impl.StdSchedulerFactory;

/**
 * @author songxulin
 * @date 2022/3/19
 */
public class TestJob {
    public static void main(String[] args) {
        JobDetail build = JobBuilder.newJob(MyJob.class)
                .withIdentity("job1", "group1")
                .usingJobData("job","描述")
                .usingJobData("name","JobDetail")
                .usingJobData("count",0)
                .build();
        Trigger trigger1 = TriggerBuilder.newTrigger()
                .withIdentity("trigger1")
                .usingJobData("trigger","描述")
                .usingJobData("count",0)
                .withSchedule(SimpleScheduleBuilder.simpleSchedule().withIntervalInSeconds(1).repeatForever()).build();
        try {
            Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
            scheduler.scheduleJob(build,trigger1);
            scheduler.start();
        }catch (Exception e){
            e.printStackTrace();
        }

    }
}
